package com.lili.collection.jdbc.config;

import com.lili.collection.core.config.InputConfig;
import com.lili.collection.core.plugins.InputPlugin;
import com.lili.collection.core.support.ConfigFieldDef;
import com.lili.collection.jdbc.plugins.JdbcInputPlugin;
import lombok.Data;

/**
 * Jdbc输入配置
 *
 * @author lili
 * @date 2023/2/13 20:41
 */
@Data
public class JdbcInputConfig extends HikariPoolConfig implements InputConfig {

    @ConfigFieldDef(type = ConfigFieldDef.Type.STRING, required = true)
    private String sql;

    @ConfigFieldDef(type = ConfigFieldDef.Type.INTEGER, required = true)
    private int batchSize = 1000;

    @ConfigFieldDef(type = ConfigFieldDef.Type.BOOLEAN, required = true)
    private boolean isNextMode = false;

    @ConfigFieldDef(type = ConfigFieldDef.Type.INTEGER, required = false)
    private int maxClobSize = 1000;

    @ConfigFieldDef(type = ConfigFieldDef.Type.INTEGER, required = false)
    private int maxBlobSize = 1000;

    @Override
    public String getOffsetColumn(){
        return super.getOffsetColumn();
    }

    public JdbcInputConfig() {
        this.setReadOnly(true);
        this.setAutoCommit(false);
    }

    @Override
    public InputPlugin getPlugin() {
        return new JdbcInputPlugin();
    }
}
